//
//  RoundedTextField.m
//  VivaModa
//
//  Created by Owly MacBook on 07.02.13.
//  Copyright (c) 2013 private_busines. All rights reserved.
//

#import "RoundedTextField.h"
#import <QuartzCore/QuartzCore.h>


@implementation RoundedTextField

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configureTextField];
        //self.layer.cornerRadius = 4;
        // Initialization code
    }
    return self;
}


// если создается из Interface Builder
-(id) initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    //self.layer.cornerRadius = 4;
    [self configureTextField];
    return self;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/



-(void)configureTextField{
    UIImage *bkImg = [UIImage imageNamed:@"price_bg"];//[[UIImage imageNamed:@"price_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
    [self setBackground:bkImg];
}



- (CGRect) adjustBoundsFromBounds:(CGRect)bounds
{
    return CGRectInset(bounds, 4.0, 0);
}

- (CGRect)borderRectForBounds:(CGRect)bounds
{
    return [super borderRectForBounds:[self adjustBoundsFromBounds:bounds]];
}
- (CGRect)textRectForBounds:(CGRect)bounds
{
    return [super textRectForBounds:[self adjustBoundsFromBounds:bounds]];
}
- (CGRect)editingRectForBounds:(CGRect)bounds
{
    return [super editingRectForBounds:[self adjustBoundsFromBounds:bounds]];
}
- (CGRect)leftViewRectForBounds:(CGRect)bounds
{
    return [super leftViewRectForBounds:[self adjustBoundsFromBounds:bounds]];
}
- (CGRect)rightViewRectForBounds:(CGRect)bounds
{
    return [super rightViewRectForBounds:[self adjustBoundsFromBounds:bounds]];
}

@end
